<?php
if (!defined('ABSPATH')) {
	define('ABSPATH', dirname(dirname(__FILE__)) . '/');
}

require_once ABSPATH . 'dr-config.php';
require_once ABSPATH . DRINC . '/dr-base.php';
require_once ABSPATH . DRINC . '/dr-functions.php';
require_once ABSPATH . DRINC . '/dr-themes.php';

require_once ABSPATH . DRINC . '/dr-smarty.php';

require_once ABSPATH . DRINC . '/dr-page-check-login.php';

$user_id = dr_is_login_on();

//发送HTTP协议，执行dr-app-tag-list.php文件内容
$order = dr_get('order');
$rank = dr_get('rank');

$orders = array('number', 'newest', 'oldest', 'name');
$posts = array('action' => 'get_user_list');
if (in_array($order, $orders)) {
	$posts['order'] = $order;
} else {
	$order = 'name';
	$posts['order'] = 'name';
}

if (!in_array($rank, array('d5', 'w5', 'm5', 'a5')))
	$rank = '';

$posts['user_id'] = $user_id;
$posts['match_str'] = '';
$posts['rank'] = $rank;


$result = dr_server_request('dr-app-users.php', $posts);
$result_array = json_decode($result, 1);


//var_dump($result_array['users']);
//将数据转换成html格式后输出
dr_to_html($result_array['users']);

$smarty->assign('page_title', '用户 - ' . get_site_name());

$smarty->assign('is_login', $user_id);
$smarty->assign('user_id', $user_id);
$smarty->assign('rank', $rank);
$smarty->assign('users', $result_array['users']);
$smarty->assign('setting', $result_array['setting']);
$smarty->assign('topNum', $result_array['topNum']);


$content = array();
$content['top_navs'] = get_page_top_navigation();
$content['menus'] = get_page_menus('users');
$content['tabs'] = get_page_tabs('users-old', $order);

$smarty->assign('content', $content);


$smarty->display('users.tpl');
